<?php
namespace Admin\Controller;
use Think\Controller;
class UserAddController extends CommonController{
    public function index(){
        $this->list=M("user_address a")
            ->join('left join agency_user_list b on a.user_id=b.user_id')
            ->field("a.*,b.username")
            ->select();
        $this->display();
    }
    public function edit(){
        $id=I("get.id");
        $this->info=M('user_address')->where(array("address_id"=>$id))->find();
        if (IS_POST){
            $data=I('post.');

            if(M("user_address")->save($data)){
                $this->success("更新成功","index",1);die;
            }else{
                $this->error("更新失败","",1);die;
            }
        }
        $this->display();
    }
    public  function del(){
        $id=I("get.id");
        $data['state']=0;
//        $res=M('user_address')->where(array("address_id"=>$id))->save($data);
        if(M('user_address')->where(array("address_id"=>$id))->save($data)){
            $this->success("删除成功","",1);die;
        }else{
            $this->error("删除失败","",1);die;
        }


    }
}